import request from "@/utils/request";
const BASE_URL = "wblog_article";
const SEARCH_BASE_URL="wblog_search"
export default {

  /**
   * 分页查询
   * @param {*} page
   * @param {*} size
   * @param {*} searchMap
   */
  searchPage(page, size, searchMap) {
    return request({
      url: `${SEARCH_BASE_URL}/article/search/${page}/${size}`,
      method: "post",
      data: searchMap
    });
  },
  /**
   * 根据文章id查询文章信息
   * @param {*} articleId
   */
  findArticleById(articleId) {
    return request({
      url: `${BASE_URL}/article/${articleId}`,
      method: "get"
    });
  },



  /**
   * 修改文章信息
   * @param {*} pojo
   */
  update(pojo) {
    return request({
      url: `${BASE_URL}/article/${pojo.article.aid}`,
      method: "put",
      data: pojo
    });
  },
  /**
   * 点赞
   * @param {*} aid 
   */
  thumbup(aid){
    return request({
      url:`${BASE_URL}/article/thumbup/${aid}`,
      method:"put"
    })
  },
  /**
   * 根据id删除文章
   * @param {*} aid
   */
  deleteById(aid) {
    return request({
      url: `${BASE_URL}/article/${aid}`,
      method: "delete"
    });
  },
  /**
   * 审核文章
   * @param {*} articleid
   */
  checkArticle(articleid) {
    return request({
      url: `${BASE_URL}/article/checkArticle/${articleid}`,
      method: "put"
    });
  },
  /**
   * 根据标签id分页查询文章列表
   * @param {*} page 当前页
   * @param {*} size 每页大小
   * @param {*} searchMap 查询条件
   * @param {*} tagid 标签id
   */
  findByTagId(page, size, searchMap, tagid) {
    return request({
      url: `${BASE_URL}/article/search/${page}/${size}/${tagid}}`,
      method: "post",
      data: searchMap
    });
  },

 

  
  /**
   * 通过用户id查询热门文章列表
   * @param {*} userid
   */
  findByUserId(userid, searchMap) {
    return request({
      url: `${BASE_URL}/article/user/hot/${userid}`,
      method: "post",
      data: searchMap
    });
  },
  /**
   * 通过用户id查询文章列表
   * @param {*} userid
   */
  findAllByUserId(page, size, userid, searchMap) {
    return request({
      url: `${BASE_URL}/article/user/${page}/${size}/${userid}`,
      method: "post",
      data: searchMap
    });
  },
 
};
/**
 * 发布文章
 * @param {*} articleParam
 */
export function publishArticle(articleParam) {
  return request({
    url: `${BASE_URL}/article`,
    method: "post",
    data: articleParam
  });
}
